<template>
  <div>
    <div class="myRobot myRobotSetUp">
      <robotNav></robotNav>
      <div class="myRobotRight">
        <div class="myRobotSetUp_body">
          <div class="myRobotRight_title">
            <div class="myRobotRight_title_dd">设置</div>
          </div>
          <div class="myRobotSetUpNav">
            <div class="myRobotSetUpNav_list notBlue" @click="changeTab(1)" :class="{ active: activeTab === 1 }">基本设置</div>
            <div class="myRobotSetUpNav_list notBlue" @click="changeTab(2)" :class="{ active: activeTab === 2 }">样式设置</div>
            <div class="myRobotSetUpNav_list notBlue" @click="changeTab(3)" :class="{ active: activeTab === 3 }">对话触达</div>
          </div>
          <div class="myRobotSetUp_content">
            <div class="BasicSettings" v-if="activeTab == 1">
              <div class="BasicSettings_left">
                <div class="myRobotSetUp_content_list">
                  <div class="content_list_dd">机器人名称</div>
                  <div class="content_list_dt">
                    <el-input v-model="robot.name" placeholder="输入机器人名称"></el-input>
                  </div>
                </div>
                <div class="myRobotSetUp_content_list">
                  <div class="content_list_dd">描述</div>
                  <div class="content_list_dt">
                    <el-input
                      type="textarea"
                      :rows="4"
                      placeholder="描述内容"
                      v-model="robot.brief_introduction">
                    </el-input>
                  </div>
                </div>			
			  <div class="myRobotSetUp_content_list w49">
				<div class="content_list_dd">模型选择</div>
				<div class="content_list_dt">
					<el-checkbox label="知识库" checked v-model="checked1" disabled></el-checkbox>
					<el-checkbox label="GPT模型" name="type2" v-model="robot.is_gpt_answer" :true-label="1"
                       :false-label="0"></el-checkbox>
				</div>
			  </div>	
				
<!--                <div class="flex">-->
<!--                  <div class="myRobotSetUp_content_list w49">-->
<!--                    <div class="content_list_dd">模型选择</div>-->
<!--                    <div class="content_list_dt">-->
<!--                      <el-select v-model="value" placeholder="请选择">-->
<!--                        <el-option-->
<!--                          v-for="item in options"-->
<!--                          :key="item.value"-->
<!--                          :label="item.label"-->
<!--                          :value="item.value">-->
<!--                        </el-option>-->
<!--                      </el-select>-->
<!--                    </div>-->
<!--                  </div>-->
<!--                  <div class="myRobotSetUp_content_list w49">-->
<!--                    <div class="content_list_dd">语气</div>-->
<!--                    <div class="content_list_dt">-->
<!--                      <el-select v-model="value2" placeholder="请选择">-->
<!--                        <el-option-->
<!--                          v-for="item in options2"-->
<!--                          :key="item.value"-->
<!--                          :label="item.label"-->
<!--                          :value="item.value">-->
<!--                        </el-option>-->
<!--                      </el-select>-->
<!--                    </div>-->
<!--                  </div>-->
<!--                </div>-->
                <div class="myRobotSetUp_content_btn notBlue" @click="save">保存</div>
              </div>
            </div>
            <div class="BasicSettings" v-if="activeTab == 2">
              <div class="BasicSettings_left ovauto2">
                <div class="myRobotSetUp_content_list">
                  <div class="content_list_dd">标题</div>
                  <div class="content_list_dt">
                    <el-input v-model="robot.title" placeholder="标题内容"></el-input>
                  </div>
                </div>
                <div class="myRobotSetUp_content_list">
                  <div class="content_list_dd">副标题</div>
                  <div class="content_list_dt">
                    <el-input v-model="robot.subtitle" placeholder="副标题内容"></el-input>
                  </div>
                </div>
                <div class="myRobotSetUp_content_list icon">
                  <div class="content_list_dd">咨询图标</div>
                  <div class="content_list_dt">
                    <div class="list_dt_left"><img :src="robot.consultation_icon ? robot.consultation_icon : imageUrl" /></div>
                    <div class="list_dt_btn notBlue">
                      <el-upload
                          class="upload-demo"
                          :action="this.baseURL + '/api1/robot/upload'"
                          :headers="{ 'Authorization' : token}"
                          :on-error="handleError"
                          :on-success="handleSuccess"
                          :data="{'robot_id': this.$store.getters.robotId}"
                          :show-file-list="false">
                        <input type="text" value="选择文件">选择文件
                      </el-upload>
                    </div>
                  </div>
                </div>
                <div class="myRobotSetUp_content_list">
                  <div class="content_list_dd">开场语</div>
                  <div class="content_list_dt">
                    <el-input
                      type="textarea"
                      :rows="4"
                      placeholder="开场语内容"
                      v-model="robot.opening_remarks">
                    </el-input>
                  </div>
                </div>			
                <div class="myRobotSetUp_content_list">
                  <div class="content_list_dd">预置提问选项</div>
                  <div class="content_list_dt">
                    <el-input
                      type="textarea"
                      :rows="4"
                      placeholder="预置提问选项"
                      v-model="robot.preset_questioning_options">
                    </el-input>
                  </div>
<!--                  <div class="content_list_p"><img src="@a/img/sv47.svg"/>一行一个</div>-->
                </div>
                <div class="myRobotSetUp_content_list">
                  <div class="content_list_dd">未找到匹配结果返回内容</div>
                  <div class="content_list_dt">
                    <el-input
                      type="textarea"
                      :rows="4"
                      placeholder="当未找到答案返回给用户的结果,如:抱歉我还在学习中,暂时没有找到您的答案."
                      v-model="robot.unable_to_answer_content">
                    </el-input>
                  </div>
                </div>						
<!--                <div class="myRobotSetUp_content_list Advanced">-->
<!--                  <div class="content_list_dd">高级样式设置<span>非专业技术请勿操作</span></div>-->
<!--                  <div class="content_list_dt">-->
<!--                    <el-input-->
<!--                      type="textarea"-->
<!--                      :rows="4"-->
<!--                      placeholder="高级样式设置"-->
<!--                      v-model="robot.advanced_style_settings">-->
<!--                    </el-input>-->
<!--                  </div>-->
<!--                  <a href="#" class="content_list_a">css样式帮助中心</a>-->
<!--                </div>-->
                <div class="myRobotSetUp_content_btn notBlue" @click="save">保存</div>
              </div>
              <div class="BasicSettings_right">
                <div class="BasicSettings_right_title">聊天机器人预览</div>
                <div class="BasicSettings_right_content">
                  <div class="right_content_top">
                    <div class="content_top_dd">我的机器人</div>
                    <div class="content_top_dt">你可以问我任何事情</div>
                  </div>
                  <div class="right_content_con">
                    <div class="right_content_txt ovauto2">
                      <div class="myRobotUserDialog_right_bottom">
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="https://api.ai-dog.net//dogs/Bulldog.png" /></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt"><div class="right_txt_dd">嗯，你们的公司叫什么？</div></div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="@a/img/bg30.jpg"/></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt">
                                <div class="right_txt_dd">我们公司的名称是上海集锦信息科技有限公司。</div>
                                <div class="right_txt_dt">
                                  <div class="question_icon_li notBlue active"><img src="@a/img/sv68on.svg"/><img src="@a/img/sv68.svg"/></div>
                                  <div class="question_icon_li notBlue"><img src="@a/img/sv69on.svg"/><img src="@a/img/sv69.svg"/></div>
                                </div>
                              </div>
                              <div class="list_right_source" @click="toggleClass" :class="{ 'active': isActive }">
                                <div class="right_source_title notBlue">查看来源<i class="el-icon-arrow-down"></i></div>
                                <div class="right_source_down">
                                  <a href="#" class="source_down_list">/解决方案/5.html</a>
                                  <a href="#" class="source_down_list">/新闻/37679.html</a>
                                  <a href="#" class="source_down_list">/关于/index.html</a>
                                </div>
                              </div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="https://api.ai-dog.net//dogs/Bulldog.png" /></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt"><div class="right_txt_dd">你们的主要业务是什么？</div></div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="@a/img/bg30.jpg"/></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt">
                                <div class="right_txt_dd">我们公司的主要业务包括网站建设、电商平台建设、小程序开发、APP开发服务、数字化运营、数字营销等方面的服务。我们致力于为客户提供专业、高效、一站式的解决方案，帮助客户提高业务效率和品牌影响力。</div>
                                <div class="right_txt_dt">
                                  <div class="question_icon_li notBlue active"><img src="@a/img/sv68on.svg"/><img src="@a/img/sv68.svg"/></div>
                                  <div class="question_icon_li notBlue"><img src="@a/img/sv69on.svg"/><img src="@a/img/sv69.svg"/></div>
                                </div>
                              </div>
                              <div class="list_right_source" @click="toggleClass" :class="{ 'active': isActive }">
                                <div class="right_source_title notBlue">查看来源<i class="el-icon-arrow-down"></i></div>
                                <div class="right_source_down">
                                  <a href="#" class="source_down_list">/解决方案/5.html</a>
                                  <a href="#" class="source_down_list">/新闻/37679.html</a>
                                  <a href="#" class="source_down_list">/关于/index.html</a>
                                </div>
                              </div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="https://api.ai-dog.net//dogs/Bulldog.png" /></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt"><div class="right_txt_dd">你们的主要业务是什么？</div></div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="@a/img/bg30.jpg"/></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt">
                                <div class="right_txt_dd">我们公司的主要业务包括网站建设、电商平台建设、小程序开发、APP开发服务、数字化运营、数字营销等方面的服务。我们致力于为客户提供专业、高效、一站式的解决方案，帮助客户提高业务效率和品牌影响力。</div>
                                <div class="right_txt_dt">
                                  <div class="question_icon_li notBlue active"><img src="@a/img/sv68on.svg"/><img src="@a/img/sv68.svg"/></div>
                                  <div class="question_icon_li notBlue"><img src="@a/img/sv69on.svg"/><img src="@a/img/sv69.svg"/></div>
                                </div>
                              </div>
                              <div class="list_right_source" @click="toggleClass" :class="{ 'active': isActive }">
                                <div class="right_source_title notBlue">查看来源<i class="el-icon-arrow-down"></i></div>
                                <div class="right_source_down">
                                  <a href="#" class="source_down_list">/解决方案/5.html</a>
                                  <a href="#" class="source_down_list">/新闻/37679.html</a>
                                  <a href="#" class="source_down_list">/关于/index.html</a>
                                </div>
                              </div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="https://api.ai-dog.net//dogs/Bulldog.png" /></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt"><div class="right_txt_dd">你们的主要业务是什么？</div></div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="@a/img/bg30.jpg"/></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt">
                                <div class="right_txt_dd">我们公司的主要业务包括网站建设、电商平台建设、小程序开发、APP开发服务、数字化运营、数字营销等方面的服务。我们致力于为客户提供专业、高效、一站式的解决方案，帮助客户提高业务效率和品牌影响力。</div>
                                <div class="right_txt_dt">
                                  <div class="question_icon_li notBlue"><img src="@a/img/sv68on.svg"/><img src="@a/img/sv68.svg"/></div>
                                  <div class="question_icon_li notBlue active"><img src="@a/img/sv69on.svg"/><img src="@a/img/sv69.svg"/></div>
                                </div>
                              </div>
                              <div class="list_right_source" @click="toggleClass" :class="{ 'active': isActive }">
                                <div class="right_source_title notBlue">查看来源<i class="el-icon-arrow-down"></i></div>
                                <div class="right_source_down">
                                  <a href="#" class="source_down_list">/解决方案/5.html</a>
                                  <a href="#" class="source_down_list">/新闻/37679.html</a>
                                  <a href="#" class="source_down_list">/关于/index.html</a>
                                </div>
                              </div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="https://api.ai-dog.net//dogs/Bulldog.png" /></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt"><div class="right_txt_dd">你们的主要业务是什么？</div></div>
                            </div>
                          </div>
                          <div class="right_bottom_list">
                            <div class="bottom_list_left"><img src="@a/img/bg30.jpg"/></div>
                            <div class="bottom_list_right">
                              <div class="list_right_time">2023-06-14 18:46:36</div>
                              <div class="list_right_txt">
                                <div class="right_txt_dd">我们公司的主要业务包括网站建设、电商平台建设、小程序开发、APP开发服务、数字化运营、数字营销等方面的服务。我们致力于为客户提供专业、高效、一站式的解决方案，帮助客户提高业务效率和品牌影响力。</div>
                                <div class="right_txt_dt">
                                  <div class="question_icon_li notBlue"><img src="@a/img/sv68on.svg"/><img src="@a/img/sv68.svg"/></div>
                                  <div class="question_icon_li notBlue active"><img src="@a/img/sv69on.svg"/><img src="@a/img/sv69.svg"/></div>
                                </div>
                              </div>
                              <div class="list_right_source" @click="toggleClass" :class="{ 'active': isActive }">
                                <div class="right_source_title notBlue">查看来源<i class="el-icon-arrow-down"></i></div>
                                <div class="right_source_down">
                                  <a href="#" class="source_down_list">/解决方案/5.html</a>
                                  <a href="#" class="source_down_list">/新闻/37679.html</a>
                                  <a href="#" class="source_down_list">/关于/index.html</a>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                    </div>
                    <div class="right_submit_input">
                      <div class="submit_input_left">
                        <el-input
                          type="textarea"
                          :rows="1"
                          placeholder="提问区域"
                          v-model="textarea6">
                        </el-input>
                      </div>
                      <div class="submit_input_btn notBlue"><img src="@a/img/sv33.png"/></div>
                    </div>
                    <div class="right_content_bottom">Powered by <a href="#">AIDOG</a></div>
                  </div>
                </div>
              </div>
            </div>
            <div class="DialogueReach" v-if="activeTab == 3">
              <div class="DialogueReach_tab">
                <div class="DialogueReach_tab_list" >
                  <div class="tab_list_li">名称</div>
                  <div class="tab_list_li">触达条件(对话包含相关内容)</div>
                  <div class="tab_list_li">执行动作</div>
                  <div class="tab_list_li">操作</div>
                </div>
                <div class="DialogueReach_tab_list" v-for="(event, index) in eventList" :key="index">
                  <div class="tab_list_li">{{ event.name }}</div>
                  <div class="tab_list_li" >
                    {{event.trigger_text}}
                  </div>
                  <div class="tab_list_li">收集表单：<span v-for="(field, field_index) in  event.form_field" :key="field"> {{field_index?'+ ':''}}{{ field }} </span></div>
                  <div class="tab_list_li">
                    <a class="notBlue" @click="editEvent(event)">编辑</a>
                    <a  class="notBlue" @click="confirmDeleteEvent(event)">删除</a>
                  </div>
                </div>
              </div>
              <div class="DialogueReach_btn notBlue" @click="addEvent">添加</div>
              <div class="BasicSettings">
                <div class="BasicSettings_left ovauto2">
                  <div class="DialogueReach_BasicSettingstitle">👉 当用户发送的对话内容包含指定本关词的时候会触达相关动作，比如：</div>
                  <div class="DialogueReach_BasicSettingstxt">
                    <div class="DialogueReach_BasicSettingstxt_list">
                      <div class="BasicSettingstxt_list_dd">用户输入</div>
                      <div class="BasicSettingstxt_list_dt">如何可以成为你们的代理商，在AI在回答内容后可以让用户填写一个表单，便于我们与用户取得联系。</div>
                    </div>
                    <div class="DialogueReach_BasicSettingstxt_list">
                      <div class="BasicSettingstxt_list_dd">用户输入</div>
                      <div class="BasicSettingstxt_list_dt">转人工，人工咨询可以对接或者推送内容到第三方接口并转入人工客服。</div>
                    </div>
                  </div>
                </div>
                <div class="BasicSettings_right">
                  <div class="BasicSettings_right_title">聊天机器人预览</div>
                  <div class="BasicSettings_right_content">
                    <div class="right_content_top">
                      <div class="content_top_dd">我的机器人</div>
                      <div class="content_top_dt">你可以问我任何事情</div>
                    </div>
                    <div class="right_content_con">
                      <div class="right_content_txt ovauto2">
                        <div class="myRobotUserDialog_right_bottom">
                            <div class="right_bottom_list">
                              <div class="bottom_list_left"><img src="https://api.ai-dog.net//dogs/Bulldog.png" /></div>
                              <div class="bottom_list_right">
                                <div class="list_right_time">2023-06-14 18:46:36</div>
                                <div class="list_right_txt"><div class="right_txt_dd">如何成为你们的代理商？</div></div>
                              </div>
                            </div>
                            <div class="right_bottom_list">
                              <div class="bottom_list_left"><img src="@a/img/bg30.jpg"/></div>
                              <div class="bottom_list_right">
                                <div class="list_right_time">2023-06-14 18:46:36</div>
                                <div class="list_right_txt">
                                  <div class="right_txt_dd">
                                    我们的代理商加盟要求为......<br>如果您想进一步了解，请留下您的信息我们将尽快和您联系
                                    <div class="Join">
                                      <div class="Join_list">
                                        <div class="Join_list_left">公司名称</div>
                                        <div class="Join_list_right"><el-input v-model="JoinValue1" placeholder="请输入内容"></el-input></div>
                                      </div>
                                      <div class="Join_list">
                                        <div class="Join_list_left">公司名称</div>
                                        <div class="Join_list_right"><el-input v-model="JoinValue2" placeholder="请输入内容"></el-input></div>
                                      </div>
                                      <div class="Join_list">
                                        <div class="Join_list_left">公司名称</div>
                                        <div class="Join_list_right"><el-input v-model="JoinValue3" placeholder="请输入内容"></el-input></div>
                                      </div>
                                      <div class="Join_btn notBlue">提交</div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                      </div>
                      <div class="right_submit_input">
                        <div class="submit_input_left">
                          <el-input
                            type="textarea"
                            :rows="1"
                            placeholder="提问区域"
                            v-model="textarea6">
                          </el-input>
                        </div>
                        <div class="submit_input_btn notBlue"><img src="@a/img/sv33.png"/></div>
                      </div>
                      <div class="right_content_bottom">Powered by <a href="#">AIDOG</a></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 对话触达弹窗 -->
      <div class="alRobotWindow" v-show="DialogueReach">
        <div class="alRobotWindow_content">
          <div class="alRobotWindow_content_title">
            <div class="content_title_left"><span></span>对话触达</div>
            <div class="content_title_right" @click="DialogueReach = !DialogueReach"><i class="el-icon-close"></i></div>
          </div>
          <div class="alRobotWindow_content_txt">
            <div class="content_txt_list">
              <div class="txt_list_dd">名称</div>
              <div class="txt_list_dt">
                <el-input v-model="event.name" placeholder="请输入名称"></el-input>
              </div>
            </div>
            <div class="content_txt_list">
              <div class="txt_list_dd">用户对话包含</div>
              <div class="txt_list_dt">
                <el-input
                      type="textarea"
                      :rows="4"
                      placeholder="请输入用户对话包含内容"
                      v-model="event.trigger_text">
                </el-input>
              </div>
            </div>
            <div class="content_txt_list">
              <div class="txt_list_dd">运行动作</div>
              <div class="txt_list_dt">
                <el-select v-model="event.type" placeholder="请选择">
                  <el-option
                    v-for="item in DialogueReach3"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="content_txt_list">
              <div class="txt_list_dd">表单名称</div>
              <div class="txt_list_dt">
                <el-input v-model="event.form_name" placeholder="请输入表单名称"></el-input>
              </div>
            </div>
            <div class="content_txt_list alignCenter">
              <div class="txt_list_dd">表单选项</div>
              <div class="txt_list_dt">
                <el-checkbox-group v-model="event.form_field">
                  <el-checkbox label="姓名"  ></el-checkbox>
                  <el-checkbox label="电话" ></el-checkbox>
                  <el-checkbox label="公司" ></el-checkbox>
                  <el-checkbox label="城市" ></el-checkbox>
                  <el-checkbox label="留言"></el-checkbox>
                </el-checkbox-group>
              </div>
            </div>
          </div>
          <div class="alRobotWindow_content_btn on">
            <button @click="saveEvent">保存</button>
            <button class="on" @click="DialogueReach = !DialogueReach">取消</button>
          </div>
        </div>
      </div>




    </div>

    
  </div>
</template>

<script>
    import robotNav from "@c/common/robotNav/robotNav";
    import {api} from "@/api-js";
    import {MessageBox} from "element-ui";
    import {remove} from "@/api-js/path/robotEvent";
    import {getById, update} from "@/api-js/path/robot";
    import config from "@/config";

    export default {
        data() {
            return {
              event:{
                name: '',
                trigger_text: '',
                type: '0',
                form_name: '',
                form_field: []
              },
              eventList: [],
              robot: {
                id: this.$store.getters.robotId,
              },


              DialogueReach: false,
              checkList: ['姓名'],
              DialogueReach1: '代理表单收集',
              DialogueReach2: '产品价格',
              DialogueReach3: [{
                value: '0',
                label: '表单收集'
              }],
              DialogueReach4: '如果您想进一步了解，请留下您的信息我们将尽快和您联系',
              JoinValue1: '',
              JoinValue2: '',
              JoinValue3: '',
              imageUrl: require("@a/img/sv67.svg"), // 默认图片URL
              activeTab: 1,


              baseURL: config.baseurl,
              token: localStorage.getItem('token'),
              isActive: false,
            };
        },
        components: {
          robotNav
        },
        computed: {

        },
        methods:{
          changeTab(index) {
            this.activeTab = index;
          },
          toggleClass() {
            this.isActive = !this.isActive;
          },
          uploadImage(event) {
            const file = event.target.files[0];
            const reader = new FileReader();

            reader.onload = (e) => {
              this.imageUrl = e.target.result; // 将上传的图片URL赋值给imageUrl
            };

            reader.readAsDataURL(file);
          },


          async getEventList() {
              const [e,r] = await api.robotEvent.list({
                robot_id: this.$store.getters.robotId
              });
              if(!e && r){
                this.eventList = r.result;
              }

          },
          async saveEvent() {
            const [e,r] = await api.robotEvent.save(this.event);
            if(!e && r){
              if(r.code === 1) {
                this.DialogueReach = false;
                await this.getEventList();
              }

            }

          },
          confirmDeleteEvent(event){
            MessageBox.confirm('确定删除该项吗？', '提示', {
              type: 'warning'
            })
                .then(() => {
                  this.deleteEvent(event);
                })
                .catch(() => {
                  // 取消删除操作
                });
          },
          async deleteEvent(event) {
            const [e,r] = await api.robotEvent.remove({
              robot_id: this.$store.getters.robotId,
              id: event.id
            });
            if(!e && r){
              await this.getEventList();
            }
          },
          editEvent(event) {
            this.DialogueReach = true;
            this.event = {
              name: event.name,
              trigger_text: event.trigger_text,
              type: event.type + '',
              form_name: event.form_name,
              form_field: event.form_field,
              robot_id: this.$store.getters.robotId,
              id: event.id
            };
          },
          addEvent() {
            this.DialogueReach = true;
            this.event = {
              name: '',
              trigger_text: '',
              type: '0',
              form_name: '',
              form_field: [],
              robot_id: this.$store.getters.robotId,
            }
          },
          async getRobot() {
            const [e,r] = await api.robot.getById({
              id: this.$store.getters.robotId
            });
            if(!e && r){
              this.robot = r.result
            }
          },

          async save(){
            const [e,r] = await api.robot.update(this.robot);
            if(!e && r){
              if(r.code === 1) {
                this.$message({
                  message: '保存成功',
                  type: 'success'
                });
              }
            }
          },

          handleSuccess(p1, p2){
            let url = p1.result.url;
            this.imageUrl = this.baseURL + url;
            this.robot.consultation_icon = this.imageUrl;
          },
          handleError(p1){
            this.$message({
              message: JSON.parse(p1.message).msg,
              type: 'error'
            });
          },
        },
        created() {
          this.getEventList();
          this.getRobot();
        },
    }
</script>


<style>
@import "myRobotSetUp.css";
</style>

